package com.apes.fn.scm.merchant.account.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.ApesModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.tuple.date.DateTime;
import com.apes.framework.util.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenerationTime;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * @Title: SettlementAutoCreateLog
 * @Author fj
 * @Package com.apes.fn.scm.merchant.account.model
 * @Date 2023/8/11 14:48
 * @description: 对账单定时任务创建错误日志
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = SettlementAutoCreateLog.CONST_TABLE_NAME)
public class SettlementAutoCreateLog extends ApesModel{

    public static final String CONST_TABLE_NAME = "settlement_auto_create_log";

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Comment("唯一码")
    private Integer id;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "condition", columnDefinition = "CLOB")
    @Comment("条件")
    private String condition;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "error", columnDefinition = "CLOB")
    @Comment("错误消息")
    private String error;

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @DateTime(GenerationTime.INSERT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_date", updatable = false)
    @Comment("创建时间")
    private Date createDate;

    @Column(name = "type", length = 30)
    @Comment("结算方式")
    private String type;
}
